package com.example.dormitory.controller;
import com.example.dormitory.entity.User;
import com.example.dormitory.service.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private Userservice userservice;
    @GetMapping("create")
    public void creat(){
        User user = new User();
        user.setUserName("shana");
        user.setName("Asuna");
        user.setPassworld("xianaxiana0323");
        userservice.creat(user);
    }

    @GetMapping("delete")
    public void delete(Integer id){
        userservice.delete(id);
    }

    @GetMapping("update")
    public void update(){
        User user = new User();
        user.setUserName("shanaxxxxxx");
        user.setName("Asunaxxxxxx");
        user.setPassworld("xianaxiana0323123456");
        user.setId(1);
        userservice.update(user);
    }

    @GetMapping("detail")
    public User detail(Integer id){
        return userservice.detail(id);
    }

    @GetMapping("query")
    public List<User> query(User user){
        return userservice.query(user);
    }


}
